using System;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Security;

namespace Os.WebUI.Helpers
{
	public static class AtendenteHelper
	{
		public static string loadAtendente(this HtmlHelper helper, List<MembershipUser> users, MembershipUser selectedUser)
		{
			string html = string.Empty;
			html += @"<select id='Atendente' name='Atendente'>";
			if (selectedUser == null)
			{
				html += @"<option value='-1' >Nenhum</option>";
			}
			foreach (MembershipUser current in users)
			{
				html += @"<option value='" + current.ProviderUserKey.ToString() + "'"; 
					
				if (selectedUser != null)
				{
					if (current.ProviderUserKey == selectedUser.ProviderUserKey)
					{
						html += @"selected='selected'";
					}
				}
				html += @">";
				html += current.UserName;
				html += @"</option>";
			}
			html += @"</select>";
			return html;
		}

        public static string FormatarAtendente(this HtmlHelper helper, MembershipUser user)
        {
            string result = string.Empty;
            if (user == null)
            {
                result = "Nenhum";
            }
            else
            {
                result = user.UserName;
            }
            return result;
        }
	}
}
